/*
 * @Author: liyin 2179253556@qq.com
 * @Date: 2022-11-16 08:08:04
 * @LastEditors: liyin 2179253556@qq.com
 * @LastEditTime: 2022-11-16 08:18:51
 * @FilePath: \consumption-data-screen\src\store\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import Vue from 'vue'
import Vuex from 'vuex'
// 引入 router 在vuex内使用router跳转
import router from '../router'

Vue.use(Vuex)
Vue.use(router)

export default new Vuex.Store({
  state: {
    // 一级菜单
    MenuList: [],
    // 二级菜单
    NavList: []
  },
  mutations: {
    // 全局存储设备一级菜单
    setMenuList (state, val) {
      state.MenuList = val
    },
    // 全局存储设备二级菜单
    setNavList (state, val) {
      state.NavList = val
    }
  },
  actions: {
    // 全局存储设备一级菜单
    setMenuList (context, obj) {
      context.commit('setMenuList', obj)
    },
    // 全局存储设备二级菜单
    setNavList (context, obj) {
      context.commit('setNavList', obj)
    }
  }
})
